//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#include <bsp.h>

#define _RTCCON    ((ioport_t)0x97000040) //RTC control
#define _TICNT     ((ioport_t)0x97000044) //Tick time count
#define _RTCALM    ((ioport_t)0x97000050) //RTC alarm control
#define _ALMSEC    ((ioport_t)0x97000054) //Alarm second
#define _ALMMIN    ((ioport_t)0x97000058) //Alarm minute
#define _ALMHOUR   ((ioport_t)0x9700005c) //Alarm Hour
#define _ALMDAY    ((ioport_t)0x97000060) //Alarm day
#define _ALMMON    ((ioport_t)0x97000064) //Alarm month
#define _ALMYEAR   ((ioport_t)0x97000068) //Alarm year
#define _RTCRST    ((ioport_t)0x9700006c) //RTC round reset
#define _BCDSEC    ((ioport_t)0x97000070) //BCD second
#define _BCDMIN    ((ioport_t)0x97000074) //BCD minute
#define _BCDHOUR   ((ioport_t)0x97000078) //BCD hour
#define _BCDDAY    ((ioport_t)0x9700007c) //BCD day
#define _BCDDATE   ((ioport_t)0x97000080) //BCD date
#define _BCDMON    ((ioport_t)0x97000084) //BCD month
#define _BCDYEAR   ((ioport_t)0x97000088) //BCD year

EXTERN_C void CDECL BspGetRTCTime(RTCTime *pRTCTime)
{
    pRTCTime->uYear     = Inl(_BCDYEAR);
    pRTCTime->uMonth    = Inl(_BCDMON);
    pRTCTime->uDate     = Inl(_BCDDAY);

    pRTCTime->uHours    = Inl(_BCDHOUR);
    pRTCTime->uMinutes  = Inl(_BCDMIN);
    pRTCTime->uSeconds  = Inl(_BCDSEC);

    //pRTCTime->uWeekday  = Inl(_BCDDATE);
}

EXTERN_C void CDECL BspSetRTCTime(const RTCTime *pRTCTime)
{
    // bugbug: not implemented
    kprintf ("!!!BspSetRTCTime!!!:%s\n", __FILE__);
}
